﻿using System;
using System.Web.UI.WebControls;
using BLL;

public partial class StatisticData_DiagnoseBottleneck_ProductionforAll : System.Web.UI.Page
{
    DiagnoseBottleneck dbn;
    private DateTime starttime
    {
        get { return DateTime.Parse(ViewState["starttime"].ToString()); }
        set { ViewState["starttime"] = value; }
    }
    private DateTime stoptime
    {
        get { return DateTime.Parse(ViewState["stoptime"].ToString()); }
        set { ViewState["stoptime"] = value; }
    }

    public StatisticData_DiagnoseBottleneck_ProductionforAll()
    {
        dbn = new DiagnoseBottleneck();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            starttime = DateTime.Parse(this.TextBox1.Value.Trim());
            stoptime = DateTime.Parse(this.TextBox2.Value.Trim());
        }
        catch(FormatException)
        {
            string str1 = "请检查输入的日期时间格式是否正确";
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str1 + "');</script>");
        }
        BindProduction(starttime, stoptime);
    }

    protected void BindProduction(DateTime starttime,DateTime stoptime)
    {
        this.GridView1.DataSource = dbn.GetAllProductionDT(starttime, stoptime);
        this.GridView1.DataBind();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            for (int j = 2; j < 8; j++)
            {
                if (GridView1.Rows[i].Cells[j].Text == "0")
                    GridView1.Rows[i].Cells[j].Text = "";
            }
        }
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindProduction(starttime, stoptime);
    }
}
